package com.oracle.client;

import java.lang.reflect.Proxy;

import com.oracle.dao.StudentDao;
import com.oracle.dao.UserDao;
import com.oracle.dao.impl.LogProx;
import com.oracle.dao.impl.StudentDaoImpl;
import com.oracle.dao.impl.UserDaoImpl;
import com.oracle.model.Student;
import com.oracle.model.User;

public class Test {
	public static void main(String[] args) throws Exception {
		// StudentService ss = new StudentService();
		Student student = new Student();
		student.setId(1);
		student.setName("xxx");
		// ss.addStudent(student);
		// Ioc(DI)
		// BeanFactory beanFactory = new ClassPathXmlApplicationContext();
		// StudentLogDaoImplCompose daoImpl = (StudentLogDaoImplCompose)
		// beanFactory.getBean("studentService");
		// StudentDao dao = (StudentDao)beanFactory.getBean("studentDao");
//		StudentDaoImpl dao = new StudentDaoImpl();
		// StudentLogDaoImplCompose logProxy = new StudentLogDaoImplCompose();
		// logProxy.setStudentDao(dao);
		// StudentTimeDaoImplCompose timeProxy = new
		// StudentTimeDaoImplCompose();
		// timeProxy.setStudentDao(logProxy);
		// timeProxy.save(student);
//		StudentDao studentDao = (StudentDao) Proxy.newProxyInstance(
//				dao.getClass().getClassLoader(),
//				dao.getClass().getInterfaces(),
//				new LogProx(dao));
//		studentDao.save(student);
		
		User u = new User();
		u.setId(1111);
		u.setName("yyyyyy");
		UserDao userDao = new UserDaoImpl();
		UserDao dao1 = (UserDao) Proxy.newProxyInstance(
				userDao.getClass().getClassLoader(),
				userDao.getClass().getInterfaces(),
				new LogProx(userDao));
		dao1.save(u);
		System.out.println(dao1.getClass().getInterfaces()[0].getName());

		// service.addStudent(student);
		// service.addStudent(student);

	}
}
